/*
 * @Author: hua
 * @Date: 2020-07-17 17:03:32
 * @description: 
 * @LastEditors: hua
 * @LastEditTime: 2020-07-21 15:26:54
 */
/*
 * @Author: hua
 * @Date: 2020-07-17 17:03:32
 * @description: 
 * @LastEditors: hua
 * @LastEditTime: 2020-07-21 13:01:42
 */
import { login, logout, getInfo } from '@/api/login'
import { getToken, getUserInfo } from '@/utils/auth'

const user = {
  state: {
    token: getToken(),
    roles: [],
    userInfo: getUserInfo() ? getUserInfo() : {
      creationDate: "",
      id: 0,
      lastLoginTime: "",
      lastModifiedDate: "",
      name: "",
      password: "",
      username: "",
    }
  },
  getters: {
    userInfo(state) {
      return state.userInfo
    }
  },
  mutations: {
    SET_TOKEN: (state, token) => {
      state.token = token
    },
    SET_USER_INFO: (state, userInfo) => {
      state.userInfo = userInfo
    },
    SET_ROLES: (state, roles) => {
      state.roles = roles
    }
  },

  actions: {
  }
}

export default user
